<template>
  <div class="add_box">
    <div class="add_container"></div>
    <div class="add_icon_1"></div>
    <div class="add_icon_2"></div>
    <el-popover popper-class="add_popper" placement="right-start" width="290" trigger="hover">
      <div v-for="(item, index) in addData" :key="index">
        <span class="add_node_span">{{item.title}}</span>
        <div class="add_node">
          <div @click="addNode(cell.type, cell.name)" v-for="(cell, index) in item.listData" :key="index">
            <img :src="cell.imgUrl" />
            {{cell.name}}
          </div>
        </div>
      </div>
      <div slot="reference" class="add_hover"></div>
    </el-popover>
  </div>
</template>

<script>
import { addData } from '@/components/WorkFlow/Data/WorkFlowData'

export default {
  props: {
    WrapOrBranch: {
      required: true,
      type: String,
      default: 'isWrap'
    },
    index: {
      required: false,
      type: Number,
      default: -1
    }
  },
  data () {
    return {
      addData
    }
  },
  methods: {
    addNode (type, name) {
      if (type === 8 || type === 9) {
        this.$emit('addBranchNode', this.WrapOrBranch, this.index, type, name)
      } else {
        this.$emit('addWrapNode', this.WrapOrBranch, this.index, type, name)
      }
    }
  }
}
</script>

<style scoped>

/* 添加条件按钮 */

.add_box{
  width: 100px;
  position: relative;
  height: 72px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.add_box::before{
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background-color: #DEDEDE;
}
.add_container{
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: .3s all;
  background-color: #0089FF;
}
.add_icon_1{
  z-index: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 0;
  transition: .3s all;
  background-color: #FFF;
}
.add_icon_2{
  z-index: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 2px;
  transition: .3s all;
  background-color: #FFF;
}
.add_box:hover .add_container{
  width: 30px;
  height: 30px;
}
.add_box:hover>.add_icon_1{
  height: 12px;
}
.add_box:hover>.add_icon_2{
  width: 12px;
}
.add_hover{
  z-index: 2;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.add_node_span{
  font-size: 12px;
}
.add_node{
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  color: #FFF;
}
.add_node>div{
  cursor: pointer;
  box-sizing: border-box;
  width: 140px;
  padding: 4px 6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  border-radius: 4px;
  border: 1px solid #2E2E2F;
}
.add_node>div:hover{
  background-color: #3B3B3B;
  border: 1px solid #585859;
}
.add_node>div>img{
  margin-right: 6px;
  border-radius: 50%;
}
</style>
